package com.woniuxy.hrp.web;

import com.woniuxy.hrp.entity.ArrangeTime;
import com.woniuxy.hrp.entity.DoctorAndPatientAndItem;
import com.woniuxy.hrp.service.DoctorAndPatientAndItemService;
import com.woniuxy.hrp.unityhandler.ResponseEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description：
 * @Author：曹杰克
 * @CreateTime：2022/9/7 17:50
 */
@Transactional
@RestController
@CrossOrigin
@RequestMapping("/api/v1/DoctorAndPatientAndItem")
@ResponseBody
public class DoctorAndPatientAndItemController {
    @Autowired
    private DoctorAndPatientAndItemService doctorAndPatientAndItemService;
    @RequestMapping("/getItem")
    public List<DoctorAndPatientAndItem> getMitemBymrecord(int mrecord) {
        List<DoctorAndPatientAndItem> allMitem = doctorAndPatientAndItemService.selectByMrecordId(mrecord);
        return allMitem;
    }


    /**
     * 添加DoctorAndPatientAndItem
     * @param doctorAndPatientAndItem
     * @return
     */
    @RequestMapping("/add")
    public ResponseEntity add(@RequestBody DoctorAndPatientAndItem doctorAndPatientAndItem) {
        doctorAndPatientAndItemService.add(doctorAndPatientAndItem);
        return ResponseEntity.SUCCESS;
    }


    @RequestMapping("/getall")
    public ResponseEntity<List<DoctorAndPatientAndItem>> getAll() {
        List<DoctorAndPatientAndItem> listItem = doctorAndPatientAndItemService.getAll();
       return new ResponseEntity<List<DoctorAndPatientAndItem>>("200", "success", listItem);

    }

    @RequestMapping("/finddpi/{id}")
    public ResponseEntity getById(@PathVariable(value = "id")int id) {
        DoctorAndPatientAndItem getbyid = doctorAndPatientAndItemService.getById(id);
        return new ResponseEntity("200", "success", getbyid);
    }

    //当状态为Y（已完成支付），患者做好检查后，管理员可以添加检查报告 更新增加：检查报告
    @RequestMapping("/updateresult")
    public ResponseEntity updateResultByStatus(@RequestBody DoctorAndPatientAndItem doctorAndPatientAndItem) {
        doctorAndPatientAndItemService.updateById(doctorAndPatientAndItem);
        return ResponseEntity.SUCCESS;
    }

}
